home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14416 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: ix.netcom.com!netnews
  2. From: jdmorris@ix.netcom.com (Jason D. Morris)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Bletcherous kludge!
  5. Date: Sat, 30 Mar 1996 03:46:55 GMT
  6. Organization: Netcom
  7. Message-ID: <315cae79.3988595@nntp.ix.netcom.com>
  8. References: <4jhr2b$9ou@portal.gmu.edu>
  9. NNTP-Posting-Host: pon-mi2-25.ix.netcom.com
  10. X-NETCOM-Date: Fri Mar 29  7:46:02 PM PST 1996
  11. X-Newsreader: Forte Agent .99d/32.182
  12.  
  13. On 29 Mar 1996 23:17:31 GMT, rraffer1@osf1.gmu.edu (Ryan M Rafferty)
  14. wrote:
  15.  
  16. >#include "String.h"
  17. >
  18. >float String::Number() {
  19. >
  20. >  float i = 0;
  21. >
  22. >  // this conversion method is, in its current state, a HORRIBLE and
  23. >  // AWFUL kludge to convert the contents of a String instance to a
  24. >  // numeric type.  It doesn't do any error checking, but what's worse,
  25. >  // it USES A TEMPORARY FILE !!!! I'm so mad at myself!  But I can't
  26. >  // seem to be able to bend the will of the iostreams class to do what
  27. >  // I want!
  28. >
  29. >  ofstream fout("./__temp");
  30. >  fout << Buffer;
  31. >  fout.close();
  32. >  ifstream fin("./__temp");
  33. >  fin >> i;
  34. >  fin.close();
  35. >
  36. >  //      YECH!  A feeble attempt to hide my shame...
  37. >  //      execl("/bin/rm", "rm", "./__temp", (char *) 0);
  38. >
  39. >  return i;
  40. >};
  41.  
  42. Why not just fall back on atof()?
  43.  
  44. Jason
  45.